﻿namespace DesignModeConsole.结构型.桥接模式;

public abstract class Log
{
    //这点我感觉应该使用构造函数的方式更合适
    protected ImpLog implementor;

    public ImpLog Implementor
    {
        set { implementor = value; }
    }

    public virtual void Write(string log)
    {
        implementor.Equals(log);
    }
}

public class DatabaseLog : Log
{
    public override void Write(string log)
    {
        implementor.Excute(log);
    }
}

public class TextFileLog : Log
{
    public override void Write(string log)
    {
        implementor.Excute(log);
    }
}

/// <summary>
/// 日志记录在不同平台实现的基类
/// </summary>
public abstract class ImpLog
{
    public abstract void Excute(string msg);
}

public class Nlog : ImpLog
{
    public override void Excute(string msg)
    {
        Console.WriteLine("在.Net平台的实现");
    }
}

public class Jlog : ImpLog
{
    public override void Excute(string msg)
    {
        Console.WriteLine("在java平台的实现");
    }
}